#!/usr/bin/env python
from astropy.io import fits
import sys
import numpy as np

mask = fits.getdata(sys.argv[1])
bad = fits.getdata(sys.argv[2])
mask1 = mask.copy()
rows = np.unique(np.where(bad==4)[0])
print(rows)
cols = np.unique(np.where(bad==2)[1])
print(cols)
for i in range(len(rows)):
    mask1[rows[i]-3:rows[i]+3,:] = 66
for j in range(len(cols)):
    mask1[:,cols[j]-3:cols[j]+3] = 66
fits.writeto(sys.argv[3],data=mask1,overwrite=True)
